package com.supplychain.scm.core.task.config;

import com.supplychain.scm.core.task.AbstractTaskStrategy;
import com.supplychain.scm.core.task.service.TaskAsyncService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;

import java.util.List;

/**
 * @author liyang
 * @version 1.0.0
 * @ClassName TaskAsyncAutoConfiguration
 * @createTime 14:22:00 2023/04/01
 */
@Configuration
@RequiredArgsConstructor
public class TaskAsyncAutoConfiguration {

    @Nullable
    private final List<AbstractTaskStrategy> abstractTaskStrategies;

    @Bean
    @ConditionalOnMissingBean
    public TaskAsyncService taskAsyncService() {

        return new TaskAsyncService(abstractTaskStrategies);
    }
}
